/*
 * @Author: TJN tjn@246@126.com
 * @Date: 2024-06-21 15:37:10
 * @LastEditors: TJN tjn@246@126.com
 * @LastEditTime: 2024-06-25 15:46:27
 * @FilePath: \hdcms-nest\src\auth\auth.module.ts
 * @Description:
 *
 * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
 */
import { Module } from '@nestjs/common';
import { AuthService } from './auth.service';
import { AuthController } from './auth.controller';
import { JwtModule } from '@nestjs/jwt';
import { ConfigService } from 'src/common/config.service';
import { JwtStrategy } from './jwt.strategy';

@Module({
  imports: [
    JwtModule.registerAsync({
      inject: [ConfigService],
      global: true,

      useFactory(config: ConfigService) {
        return {
          secret: String(config.get('secret_key')),
          // secret: 'Admin',
          signOptions: {
            expiresIn: 3600,
          },
        };
      },
    }),
  ],
  controllers: [AuthController],
  providers: [AuthService, JwtStrategy],
})
export class AuthModule {}
